/**
 * 
 */
package me.myachievements.web.tag;

import me.myachievements.persistence.goal.Goal;
import me.myachievements.persistence.goal.GoalPersistenceManager;
import me.myachievements.persistence.tag.TagPersistenceManager;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;

/**
 * @author besseym
 *
 */
public abstract class GoalTagForm extends Form<GoalTagFormModel> {
	
	@SpringBean(name="goalPersistenceManager")
	protected GoalPersistenceManager goalPersistenceManager;
	
	@SpringBean(name="tagPersistenceManager")
	protected TagPersistenceManager tagPersistanceManager;
	
	private Goal goal;

	/**
	 * @param id
	 */
	public GoalTagForm(String id, final Goal goal) {
		super(id, new CompoundPropertyModel<GoalTagFormModel>(new GoalTagFormModel()));
		this.goal = goal;
	}

	/**
	 * @return the goal
	 */
	public Goal getGoal() {
		return goal;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
	 */
	@Override
	protected void onSubmit(){
		goalPersistenceManager.update(goal);
	}

}
